/**
 * api接口的封装
 */

import request from "../utils/request";

export default {
  // 登录
  login(params) {
    return request({
      url: "/sysAdmin/login",
      method: "post",
      data: params,
      showLoading: false, // post不显示loading
    });
  },
  // 菜单列表
  queryMenuList(params) {
    return request({
      url: "/sysMenu/list",
      method: "get",
      data: params,
    });
  },
  // 新增菜单
  addMenu(data) {
    return request({
      url: "/sysMenu/add",
      method: "post",
      data: data,
      showLoading: false,
    });
  },
  // 根据id查询菜单详情
  menuInfo(id) {
    const data = {
      id,
    };
    return request({
      url: "/sysMenu/info",
      method: "get",
      data: data,
    });
  },
  // 修改菜单
  menuUpdate(data) {
    return request({
      url: "/sysMenu/update",
      method: "put",
      data: data,
      showLoading: false,
    });
  },
  // 根据id删除菜单
  menuDelete(id) {
    const data = {
      id,
    };
    return request({
      url: "/sysMenu/delete",
      method: "delete",
      data: data,
      showLoading: false,
    });
  },
  // 角色列表
  queryRoleList(params) {
    return request({
      url: "/sysRole/list",
      method: "get",
      data: params,
    });
  },
  // 查询角色下拉列表
  querySysRoleVoList() {
    return request({
      url: "/sysRole/vo/list",
      method: "get",
    });
  },
  // 新增角色
  addRole(data) {
    return request({
      url: "/sysRole/add",
      method: "post",
      data: data,
      showLoading: false,
    });
  },
  // 根据id查询角色
  roleInfo(id) {
    const data = {
      id,
    };
    return request({
      url: "/sysRole/info",
      method: "get",
      data: data,
    });
  },
  // 角色修改
  roleUpdate(data) {
    return request({
      url: "/sysRole/update",
      method: "put",
      data: data,
      showLoading: false,
    });
  },
  // 根据id删除角色
  deleteRole(id) {
    const data = {
      id,
    };
    return request({
      url: "/sysRole/delete",
      method: "delete",
      data: data,
      showLoading: false,
    });
  },
  // 修改角色状态
  updateRoleStatus(id, status) {
    const data = {
      id,
      status,
    };
    return request({
      url: "/sysRole/updateStatus",
      method: "put",
      data: data,
      showLoading: false,
    });
  },
  // 根据id查询角色菜单列表
  queryRoleMenuIdList(id) {
    const data = {
      id,
    };
    return request({
      url: "/sysRole/vo/idList",
      method: "get",
      data: data,
    });
  },
  // 为角色分配菜单
  assignPermissions(id, menuIds) {
    const data = {
      id,
      menuIds,
    };
    return request({
      url: "/sysRole/assignPermissions",
      method: "put",
      data: data,
      showLoading: false,
    });
  },
  // 后台用户列表
  queryAdminList(params) {
    return request({
      url: "/sysAdmin/list",
      method: "get",
      data: params,
    });
  },
  // 修改后台用户状态
  updateAdminStatus(id, status) {
    const data = {
      id,
      status,
    };
    return request({
      url: "/sysAdmin/updateStatus",
      method: "put",
      data: data,
      showLoading: false,
    });
  },
  // 新增后台用户
  addAdmin(data) {
    return request({
      url: "/sysAdmin/add",
      method: "post",
      data: data,
      showLoading: false,
    });
  },
  // 根据id查询后台用户
  adminInfo(id) {
    const data = {
      id,
    };
    return request({
      url: "/sysAdmin/info",
      method: "get",
      data: data,
    });
  },
  // 修改后台用户
  adminUpdate(data) {
    return request({
      url: "/sysAdmin/update",
      method: "put",
      data: data,
      showLoading: false,
    });
  },
  // 重置密码
  resetPassword(id, password) {
    const data = {
      id,
      password,
    };
    return request({
      url: "/sysAdmin/updatePassword",
      method: "put",
      data: data,
      showLoading: false,
    });
  },
  // 根据id删除后台用户
  deleteAdmin(id) {
    const data = {
      id,
    };
    return request({
      url: "/sysAdmin/delete",
      method: "delete",
      data: data,
      showLoading: false,
    });
  },
  // 修改后台用户个人信息
  adminUpdatePersonal(data) {
    return request({
      url: "/sysAdmin/updatePersonal",
      method: "put",
      data: data,
      showLoading: false,
    });
  },
  // 修改后台用户个人密码
  adminUpdatePersonalPassword(data) {
    return request({
      url: "/sysAdmin/updatePersonalPassword",
      method: "put",
      data: data,
      showLoading: false,
    });
  },
};
